#!/usr/bin/env python
import sys

array=['_'] + [chr(i) for i in range(ord('a'), ord('z')+1)] + ['.']

def encry(s):
   key = 5
   n = len(s)
   plaincode = [array.index(i) for i in s]
   ciphercode = [(plaincode[key * i % n] - i) % 28  for i in range(n)]
   print plaincode
   print ciphercode

   print ''.join([array[ciphercode[i]] for i in range(n)])
def deencry(s, key):
    n = len(s)
    plaincode = range(n)
    ciphercode = [array.index(i) for i in s]
    for i, item in enumerate(ciphercode):
        plaincode[key * i % n] = (item + i) % 28  
    print ''.join([array[plaincode[i]] for i in range(n)])


def main():
    for line in sys.stdin:
        if line[0] != '0':
            key, string = line.split()    
            print key, string
            deencry(string, int(key))


if __name__ == '__main__':
    main()
